package xx.jwt.controller;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import xx.jwt.entity.User;
import xx.jwt.service.UserService;
import xx.jwt.util.UserThreadLocal;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@Slf4j
@RestController
@RequestMapping("/")
public class LoginController {

    @Resource
    UserService userService;

    /**
     * 登录
     *
     * @return
     */
    @PostMapping("doLogin")
    public R doLogin(@RequestBody User user) {
        return userService.login(user);
    }



    @GetMapping("doLogOut")
    public R doLogOut() {
        UserThreadLocal.remove();
        return R.ok("退出登录成功");
    }

}
